<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="sadroot" select="'../../'" />
<html>
	<head>
		<title>
			<xsl:value-of select="sadcompare/database/sourcedb/@servername" />.<xsl:value-of select="sadcompare/database/sourcedb/@databasename" /> (rev <xsl:value-of select="sadcompare/database/sourcedb/@databaserevid" />)
			
			vs xxx
			
			<xsl:value-of select="sadcompare/database/targetdb/@servername" />.<xsl:value-of select="sadcompare/database/targetdb/@databasename" /> (rev <xsl:value-of select="sadcompare/database/targetdb/@databaserevid" />)
		</title>

		<style type="text/css" rel="stylesheet">
			td
			{
			font-family: arial;
			font-size: 11px;
			}

			.ColumnData1
			{
			border-left: solid 1px grey;
			border-top: solid 1px grey;
			border-bottom: solid 1px grey;

			padding-left: 5px;

			background-color: #FFFF99;

			font-family:Arial;
			font-size:10px;
			}

			.ColumnData2
			{
			border-top: solid 1px grey;
			border-bottom: solid 1px grey;

			padding-left: 5px;
			padding-right: 5px;

			font-family:Arial;
			font-size:10px;
			}

			.ColumnData3
			{
			border-right: solid 1px grey;
			border-top: solid 1px grey;
			border-bottom: solid 1px grey;

			padding-right: 5px;

			background-color: #FFFF99;

			font-family:Arial;
			font-size:10px;
			}
		</style>
	</head>
	<body>

		<div style="font-size:14; font-weight:bold;">
			<xsl:value-of select="sadcompare/database/sourcedb/@servername" />.<xsl:value-of select="sadcompare/database/sourcedb/@databasename" /> (rev <xsl:value-of select="sadcompare/database/sourcedb/@databaserevid" />)

			vs
		
			<xsl:value-of select="sadcompare/database/targetdb/@servername" />.<xsl:value-of select="sadcompare/database/targetdb/@databasename" /> (rev <xsl:value-of select="sadcompare/database/targetdb/@databaserevid" />)
		</div>		

		<table style="border-collapse: collapse;"	>
		<tr>
			<td colspan="3" style="font-weight: bold;">Tables</td>
		</tr>

		<tr>
			<td style="border-bottom: solid 1px black;">Source Newer</td>
			<td style="border-bottom: solid 1px black;">Same Age</td>
			<td style="border-bottom: solid 1px black;">Target Newer</td>
		</tr>
				
		<xsl:for-each select="sadcompare/tables/table" >
		<xsl:variable name="SO">
			<xsl:value-of select="source/@id" />
		</xsl:variable>	
		<xsl:variable name="SR">
			<xsl:value-of select="source/@rev" />
		</xsl:variable>	
		<xsl:variable name="TO">
			<xsl:value-of select="target/@id" />
		</xsl:variable>	
		<xsl:variable name="TR">
			<xsl:value-of select="target/@rev" />
		</xsl:variable>	
		<tr>
			<td class="ColumnData1">
				<xsl:if test="@sourcenewer = 'true'">
					<a>
						<xsl:attribute name="target">
							_blank
						</xsl:attribute>	
						<xsl:attribute name="href">
							../../SQCTable.aspx?SO=<xsl:value-of select ="$SO"/>&amp;SR=<xsl:value-of select ="$SR"/>&amp;TO=<xsl:value-of select ="$TO"/>&amp;TR=<xsl:value-of select ="$TR"/>
						</xsl:attribute>
						<xsl:value-of select="@name" />
				   </a>
					<br/>
					<xsl:value-of select="source/@lastmodified" />
				</xsl:if>
			</td>
			
			<td class="ColumnData2">
				<xsl:if test="@sourceandtargetequal = 'true'">
					<a>
						<xsl:attribute name="target">
							_blank
						</xsl:attribute>
						<xsl:attribute name="href">
							../../SAD/SQCTable.aspx?SO=<xsl:value-of select ="$SO"/>&amp;SR=<xsl:value-of select ="$SR"/>&amp;TO=<xsl:value-of select ="$TO"/>&amp;TR=<xsl:value-of select ="$TR"/>
						</xsl:attribute>
						<xsl:value-of select="@name" />
					</a>
					<br/>
					<xsl:value-of select="source/@lastmodified" />
				</xsl:if>
			</td>

			<td class="ColumnData3">
				<xsl:if test="@targetnewer = 'true'">
					<a>
						<xsl:attribute name="target">
							_blank
						</xsl:attribute>
						<xsl:attribute name="href">
							../../SAD/SQCTable.aspx?SO=<xsl:value-of select ="$SO"/>&amp;SR=<xsl:value-of select ="$SR"/>&amp;TO=<xsl:value-of select ="$TO"/>&amp;TR=<xsl:value-of select ="$TR"/>
						</xsl:attribute>																																							
						<xsl:value-of select="@name" />
					</a>
					<br/>
					<xsl:value-of select="target/@lastmodified" />
				</xsl:if>
			</td>
		</tr>		
		</xsl:for-each>
		
		<tr>
			<td colspan="3" style="font-weight: bold;">Views</td>
		</tr>
		<tr>
			<td style="border-bottom: solid 1px black;">Source Newer</td>
			<td style="border-bottom: solid 1px black;"	>Same Age</td>
			<td style="border-bottom: solid 1px black;">Target Newer</td>
		</tr>
		
		<xsl:for-each select="sadcompare/views/view" >
		<xsl:variable name="SO">
			<xsl:value-of select="source/@id" />
		</xsl:variable>	
		<xsl:variable name="SR">
			<xsl:value-of select="source/@rev" />
		</xsl:variable>	
		<xsl:variable name="TO">
			<xsl:value-of select="target/@id" />
		</xsl:variable>	
		<xsl:variable name="TR">
			<xsl:value-of select="target/@rev" />
		</xsl:variable>	
		<tr>
			<td class="ColumnData1">
				<xsl:if test="@sourcenewer = 'true'">
					<a>
						<xsl:attribute name="target">
							_blank
						</xsl:attribute>
						<xsl:attribute name="href">
							../../sad/SQCView.aspx?SO=<xsl:value-of select ="$SO"/>&amp;SR=<xsl:value-of select ="$SR"/>&amp;TO=<xsl:value-of select ="$TO"/>&amp;TR=<xsl:value-of select ="$TR"/>
						</xsl:attribute>
						<xsl:value-of select="@name" />
				   </a>
					<br/>
					<xsl:value-of select="source/@lastmodified" />
				</xsl:if>
			</td>
			
			<td class="ColumnData2">
				<xsl:if test="@sourceandtargetequal = 'true'">
					<a>
						<xsl:attribute name="target">
							_blank
						</xsl:attribute>
						<xsl:attribute name="href">
							../../sad/SQCView.aspx?SO=<xsl:value-of select ="$SO"/>&amp;SR=<xsl:value-of select ="$SR"/>&amp;TO=<xsl:value-of select ="$TO"/>&amp;TR=<xsl:value-of select ="$TR"/>
						</xsl:attribute>
						<xsl:value-of select="@name" />
					</a>
					<br/>
					<xsl:value-of select="source/@lastmodified" />
				</xsl:if>
			</td>
			
			<td class="ColumnData3">
				<xsl:if test="@targetnewer = 'true'">
					<a>
						<xsl:attribute name="target">
							_blank
						</xsl:attribute>
						<xsl:attribute name="href">
							../../sad/SQCView.aspx?SO=<xsl:value-of select ="$SO"/>&amp;SR=<xsl:value-of select ="$SR"/>&amp;TO=<xsl:value-of select ="$TO"/>&amp;TR=<xsl:value-of select ="$TR"/>
						</xsl:attribute>
						<xsl:value-of select="@name" />
					</a>
					<br/>
					<xsl:value-of select="target/@lastmodified" />
				</xsl:if>
			</td>
		</tr>		
		</xsl:for-each>
		
		<tr>
			<td colspan="3" style="font-weight: bold;">Procedures</td>
		</tr>
		<tr>
			<td style="border-bottom: solid 1px black;">Source Newer</td>
			<td style="border-bottom: solid 1px black;"	>Same Age</td>
			<td style="border-bottom: solid 1px black;">Target Newer</td>
		</tr>
				
		<xsl:for-each select="sadcompare/procedures/procedure" >
		<xsl:variable name="SO">
			<xsl:value-of select="source/@id" />
		</xsl:variable>	
		<xsl:variable name="SR">
			<xsl:value-of select="source/@rev" />
		</xsl:variable>	
		<xsl:variable name="TO">
			<xsl:value-of select="target/@id" />
		</xsl:variable>	
		<xsl:variable name="TR">
			<xsl:value-of select="target/@rev" />
		</xsl:variable>	
		<tr>
			<td class="ColumnData1">
				<xsl:if test="@sourcenewer = 'true'">
					<a>
						<xsl:attribute name="target">
							_blank
						</xsl:attribute>
						<xsl:attribute name="href">
							../../sad/SQCSProc.aspx?SO=<xsl:value-of select ="$SO"/>&amp;SR=<xsl:value-of select ="$SR"/>&amp;TO=<xsl:value-of select ="$TO"/>&amp;TR=<xsl:value-of select ="$TR"/>
						</xsl:attribute>
						<xsl:value-of select="@name" />
					</a>
					<br/>
					<xsl:value-of select="source/@lastmodified" />
				</xsl:if>
			</td>
			
			<td class="ColumnData2">
				<xsl:if test="@sourceandtargetequal = 'true'">
					<a>
						<xsl:attribute name="target">
							_blank
						</xsl:attribute>
						<xsl:attribute name="href">
							../../sad/SQCSProc.aspx?SO=<xsl:value-of select ="$SO"/>&amp;SR=<xsl:value-of select ="$SR"/>&amp;TO=<xsl:value-of select ="$TO"/>&amp;TR=<xsl:value-of select ="$TR"/>
						</xsl:attribute>
						<xsl:value-of select="@name" />
					</a>
					<br/>
					<xsl:value-of select="source/@lastmodified" />
				</xsl:if>
			</td>
			
			<td class="ColumnData3">
				<xsl:if test="@targetnewer = 'true'">
					<a>
						<xsl:attribute name="target">
							_blank
						</xsl:attribute>
						<xsl:attribute name="href">
							../../sad/SQCSProc.aspx?SO=<xsl:value-of select ="$SO"/>&amp;SR=<xsl:value-of select ="$SR"/>&amp;TO=<xsl:value-of select ="$TO"/>&amp;TR=<xsl:value-of select ="$TR"/>
						</xsl:attribute>
						<xsl:value-of select="@name" />
					</a>
					<br/>
					<xsl:value-of select="target/@lastmodified" />
				</xsl:if>
			</td>
		</tr>		
		</xsl:for-each>

	<tr>
		<td colspan="3" style="font-weight: bold;">Functions</td>
	</tr>
	<tr>
		<td style="border-bottom: solid 1px black;">Source Newer</td>
		<td style="border-bottom: solid 1px black;"	>Same Age</td>
		<td style="border-bottom: solid 1px black;">Target Newer</td>
	</tr>

	<xsl:for-each select="sadcompare/functions/function" >
		<xsl:variable name="SO">
			<xsl:value-of select="source/@id" />
		</xsl:variable>
		<xsl:variable name="SR">
			<xsl:value-of select="source/@rev" />
		</xsl:variable>
		<xsl:variable name="TO">
			<xsl:value-of select="target/@id" />
		</xsl:variable>
		<xsl:variable name="TR">
			<xsl:value-of select="target/@rev" />
		</xsl:variable>
		<tr>
			<td class="ColumnData1">
				<xsl:if test="@sourcenewer = 'true'">
					<a>
						<xsl:attribute name="target">
							_blank
						</xsl:attribute>
						<xsl:attribute name="href">
							../../sad/SQCFunction.aspx?SO=<xsl:value-of select ="$SO"/>&amp;SR=<xsl:value-of select ="$SR"/>&amp;TO=<xsl:value-of select ="$TO"/>&amp;TR=<xsl:value-of select ="$TR"/>
						</xsl:attribute>
						<xsl:value-of select="@name" />
					</a>
					<br/>
					<xsl:value-of select="source/@lastmodified" />
				</xsl:if>
			</td>

			<td class="ColumnData2">
				<xsl:if test="@sourceandtargetequal = 'true'">
					<a>
						<xsl:attribute name="target">
							_blank
						</xsl:attribute>
						<xsl:attribute name="href">
							../../sad/SQCFunction.aspx?SO=<xsl:value-of select ="$SO"/>&amp;SR=<xsl:value-of select ="$SR"/>&amp;TO=<xsl:value-of select ="$TO"/>&amp;TR=<xsl:value-of select ="$TR"/>
						</xsl:attribute>
						<xsl:value-of select="@name" />
					</a>
					<br/>
					<xsl:value-of select="source/@lastmodified" />
				</xsl:if>
			</td>

			<td class="ColumnData3">
				<xsl:if test="@targetnewer = 'true'">
					<a>
						<xsl:attribute name="target">
							_blank
						</xsl:attribute>
						<xsl:attribute name="href">
							../../sad/SQCFunction.aspx?SO=<xsl:value-of select ="$SO"/>&amp;SR=<xsl:value-of select ="$SR"/>&amp;TO=<xsl:value-of select ="$TO"/>&amp;TR=<xsl:value-of select ="$TR"/>
						</xsl:attribute>
						<xsl:value-of select="@name" />
					</a>
					<br/>
					<xsl:value-of select="target/@lastmodified" />
				</xsl:if>
			</td>
		</tr>
	</xsl:for-each>
</table>

</body>
</html>

</xsl:template>
</xsl:stylesheet>